USE [NANS21V]
GO

/****** Object:  UserDefinedFunction [dbo].[RollCall]    Script Date: 04/24/2014 14:11:13 ******/
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[RollCall]') AND type in (N'FN', N'IF', N'TF', N'FS', N'FT'))
DROP FUNCTION [dbo].[RollCall]

GO

/****** Object:  UserDefinedFunction [dbo].[RollCall]    Script Date: 04/24/2014 14:11:13 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[RollCall]
(
	@HOST VARCHAR(32),
	@ROLLCALLFLG INT,
	@KINOUFLG INT
)
RETURNS VARCHAR(64)
AS
BEGIN
	DECLARE @return VARCHAR(64)

	IF (@KINOUFLG > 0)
	BEGIN
		IF (@KINOUFLG = 1) AND (@HOST IS NOT NULL AND @HOST != '')
		BEGIN
			SET @return = @HOST
			RETURN @return
		END
	END

	SELECT @return = MSG.TITLE
		FROM TBL_WEB_USE_ID ID, TBL_WEB_USE_MSG MSG
		WHERE LOWER(TAGNAME) = LOWER('RollCallState')
			AND ID.TAGID = MSG.TAGID
			AND MSG.XMLCODE = @ROLLCALLFLG

	RETURN @return
END

GO
